Imports GTSDAL
Partial Class GTSWeb_Shipment_CalculateRates
    Inherits System.Web.UI.Page

    Private ShipmentMgr As New GTSSystem.BLL.Shipment
    Private RateMgr As New GTSSystem.BLL.Rates

    Private ShipmentData As New GTSDAL.ShipmentDataTable
    Private RatesData As New Data.DataSet
    Private RatesTable As New Data.DataTable

    Private ReferenceNumber As Integer

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim OriginID, DestinationID, ServiceType, Surcharge As Integer
        Dim Weight As Double
        Dim d As Data.DataRow
        Try
            ReferenceNumber = Convert.ToInt32(Request.QueryString("ReferenceNumber"))
            Session.Add("ReferenceNumber", ReferenceNumber)
            ShipmentData = ShipmentMgr.getShipmentByReferencenumber(ReferenceNumber)
            OriginID = ShipmentData.Rows(0).Item("OriginID")
            DestinationID = ShipmentData.Rows(0).Item("DestinationID")
            Weight = ShipmentData.Rows(0).Item("Weight")
            ServiceType = ShipmentData.Rows(0).Item("ServiceTypeID")
            Surcharge = ShipmentData.Rows(0).Item("Surcharge")
            RatesData = RateMgr.GetBestRates(OriginID, DestinationID, Weight, ServiceType, Surcharge)
            RatesTable = RatesData.Tables("Rates")
            If Not (RatesTable Is Nothing) Then
                RatesData.Tables("Rates").Columns.Add("ReferenceNumber", GetType(Int32))

                For Each d In RatesData.Tables("Rates").Rows
                    d.Item("ReferenceNumber") = ReferenceNumber
                Next

                dgrRates.DataSource = RatesTable
                dgrRates.DataBind()
            Else
                lblError.Text = "System database does not has rates for the locations that you have specified."
            End If
        Catch ex As Exception
            lblError.Text = "System Error<br/>" + ex.Message + "<br/>" + ex.StackTrace
        End Try

    End Sub

  

  
End Class
